
from django.urls import path, include
from rest_framework.routers import DefaultRouter

from blog.views import (
            IndexView, CategoryView, TagView,
            ArticleDetailView, SearchView,
            MultiSearchView, ArchiveView,
        )
from blog.apis import ArticleViewSet, CategoryViewSet
from config.views import (
            LinkListView, show, delete_file, upload,
            UploadFileList, upload_file_info,
            download, delete_upload_file, GetFileByTypeView
        )
from comment.views import CommentView


router = DefaultRouter()
router.register(r'article', ArticleViewSet, basename='api-article')
router.register(r'category', CategoryViewSet, basename='api-category')


urlpatterns = [
    path('', IndexView.as_view(), name='index'),
    path('category/<int:category_id>/', CategoryView.as_view(), name='category-list'),
    path('tag/<int:tag_id>/', TagView.as_view(), name='tag-list'),
    path('article/<int:article_id>.html', ArticleDetailView.as_view(), name='article-detail'),
    path('archive/', ArchiveView.as_view(), name='archive'),


    path('links/', LinkListView.as_view(), name='links'),
    path('comment/', CommentView.as_view(), name='comment'),
    path('multi-search/', MultiSearchView.as_view(), name='multi-search'),

    path('api/', include(router.urls)),
    path('search/', SearchView.as_view(), name='search'),

    path('showimgs/', show, name='show-images'),
    path('delate-file/<str:name>/', delete_file, name='del-file'),

    path('upload/', upload, name='upload'),
    path('download/', download, name='download'),
    path('file-list/', UploadFileList.as_view(), name='file-list'),
    path('file-info/<int:f_id>/', upload_file_info, name='file-info'),
    path('delete-file/<int:f_id>/', delete_upload_file, name='delete-file'),
    path('find-file-by-type/<str:file_type>/', GetFileByTypeView.as_view(), name='ffbt'),
]
